<template>
  <div class="energy">
    <van-cell-group>
      <van-cell title="能量值" :value="infoEnergy.energy" />
      <van-cell title="奖池分红总额" :value="infoEnergy.amounts"  />
      <van-cell title="荣誉等级" :value="infoEnergy.pool"  />
      <van-cell :title="infoEnergy.love_name" :value="infoEnergy.love"  is-link @click="loveOn"/>
    </van-cell-group>
    <div class="energy-tab" >
      <van-tabs v-model:active="active" title-inactive-color="#3B3B4A" title-active-color="#F15353" @change="energyTab">
        <van-tab title="能量值记录">
          <div class="energy-list" v-if="energyList.length > 0">
            <block v-for="(item,index) in energyList" :key="index">
              <div class="energy-item">
                <div class="energy-id flex-a-c flex-j-sb">
                  <p>{{item.change_name}}</p>
                  <p v-if="Number(item.amounts) > 0">+{{item.amounts}}</p>
                  <p v-else class="minus">{{item.amounts}}</p>
                </div>
                <div class="energy-time flex-a-c flex-j-sb">
                  <p>{{item.created_at}}</p>
                </div>
              </div>
            </block>
          </div>
          <van-empty description="暂无数据" v-else/>
        </van-tab>
        <van-tab title="奖池分红记录">
          <div class="energy-list" v-if="energyList.length > 0">
            <block v-for="(item,index) in energyList" :key="index">
              <div class="energy-item">
                <div class="energy-id flex-a-c flex-j-sb">
                  <p>ID：{{item.id}}</p>
                  <p v-if="Number(item.rewards) > 0">+{{item.rewards}}</p>
                  <p v-else class="minus">{{item.rewards}}</p>
                </div>
                <div class="energy-time flex-a-c flex-j-sb">
                  <p>奖池：{{item.name}}</p>
                  <p>{{item.created_at}}</p>
                </div>
              </div>
            </block>
          </div>
          <van-empty description="暂无数据" v-else/>
        </van-tab>
      </van-tabs>
    </div>
    <div :class="[fun.isIphoneX() ? 'iphoneXStyle' : '']"></div>
  </div>
</template>
<script>
import energy_controller from "./energy_controller";
export default energy_controller;
</script>
<style scoped>
  .energy ::v-deep .van-cell__title {
    text-align: left;
    font-size: 16px;
    color: #3b3b4a;
  }

  .energy ::v-deep .van-cell__value {
    font-size: 14px;
    color: #999;
  }

  .energy ::v-deep .van-tab__text--ellipsis {
    font-size: 16px;
  }
</style>
<style lang="scss" scoped>
  .energy-tab {
    margin: 8px 0 0 0;

    .energy-list {
      background-color: #fff;
      // padding:8px 0 0 0;
      .energy-item {
        padding: 12px  0;
        margin: 0 12px;
        border-bottom: 1px solid #e7e7e7;

        .energy-id {
          padding: 0 0 8px 0;

          p:first-child {
            font-size: 14px;
            font-weight: bold;
            color: #3b3b4a;
          }

          p:last-child {
            font-size: 14px;
            font-weight: bold;
            line-height: 20px;
            color: #f15353;
          }

          .minus {
            color: #3b3b4a !important;
          }
        }

        .energy-time {
          font-size: 12px;
          color: #999;
        }
      }

      :last-child {
        .energy-item {
          border-bottom: none;
        }
      }
    }
  }

  .iphoneXStyle {
    box-sizing: content-box;
    padding-bottom: 24px;
  }
</style>